package com.jic.market.controller.manage;

import com.alibaba.fastjson.JSON;
import com.jic.common.base.vo.RestResult;
import com.jic.market.api.manage.PatchGrouponInstApi;
import com.jic.market.request.PatchGrouponInstRequest;
import com.jic.market.request.manager.patchgroup.PatchGrouponInstForceGroupRequest;
import com.jic.market.response.PageResponse;
import com.jic.market.response.PatchGrouponInstResponse;
import com.jic.market.response.manager.patchgroup.PatchGrouponInstForceGroupResponse;
import com.jic.market.service.PatchGrouponInstService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author guohuayong
 * @date: 2020年01月20日
 */
@Slf4j
@RestController
@RequestMapping("/PatchGrouponInst")
public class PatchGrouponInstController implements PatchGrouponInstApi {
    @Autowired
    PatchGrouponInstService patchGrouponInstService;

    @PostMapping("/query")
    @Override
    public RestResult<PageResponse<PatchGrouponInstResponse>> query(@RequestBody PatchGrouponInstRequest t) {
        PageResponse<PatchGrouponInstResponse> response = patchGrouponInstService.query(t);

        return RestResult.success(response);
    }

    @PostMapping("/detail")
    @Override
    public RestResult<PatchGrouponInstResponse> detail(@RequestBody PatchGrouponInstRequest t) {
        log.info("查询团单实例详情，入参{}", JSON.toJSONString(t));
        PatchGrouponInstResponse response = patchGrouponInstService.detail(t);
        log.info("查询团单实例，出参{}", JSON.toJSONString(response));
        return RestResult.success(response);
    }

    @PostMapping("/forceGroup")
    @Override
    public RestResult<PatchGrouponInstForceGroupResponse> forceGroup(
            @RequestBody PatchGrouponInstForceGroupRequest request) {
        PatchGrouponInstForceGroupResponse response =patchGrouponInstService.forceGroup(request);
        return RestResult.success(response);
    }

}
